<?php
/**
 * @var \app\model\Tweet $tweet
 */

$author = $tweet->user(); // 使用模型关系获取作者信息
?>

<div class="tweet-card">
    <div class="tweet-header">
        <strong>
            <?php if ($author): ?>
                <a href="/user/profile/<?php echo htmlspecialchars($author->username, ENT_QUOTES, 'UTF-8'); ?>">
                    <?php echo htmlspecialchars($author->username, ENT_QUOTES, 'UTF-8'); ?>
                </a>
            <?php else: ?>
                <span>[用户已删除]</span>
            <?php endif; ?>
        </strong>
        <span class="tweet-time"><?php echo date('Y-m-d H:i', $tweet->timestamp); ?></span>
    </div>
    <div class="tweet-content">
        <p><?php echo nl2br(htmlspecialchars($tweet->content, ENT_QUOTES, 'UTF-8')); ?></p>
    </div>
    <div class="tweet-actions">
        <a href="/tweet/view/<?php echo $tweet->id; ?>">查看详情 & 回复</a>
    </div>
</div>
